package day06;

import java.util.Arrays;

public class Practice {
    public static void main(String[] args) {
       /* int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {//遍历数组
            arr[i] = (int) (Math.random() * 100);
        }
        for (int i = 0; i < arr.length; i++) {//将数组打印出来
            System.out.println(arr[i]);
        }
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {//判断最大值
                max = arr[i];
            }
        }
        System.out.println("最大值是" + max);//输出最大值
        arr = Arrays.copyOf(arr, arr.length + 1);//扩容
        arr[arr.length] = max;//将最大值放在数组的最后一个元素上
        for (int i = 0; i <arr.length ; i++) {//遍历扩容后的数组并打印出来
            System.out.println(arr[i]);
        }*///MaxOfArray求数组元素最大值并放在最后一个元素的下一个位置,要求：声明整型数组并填充随机数据，找到最大值，将数组扩容并将最大值放末尾


        say();
        sayHi(27);
        sayHello("张三", 17);
        int a = getNum();
        System.out.println(a);
        int b = plus(15,23);
        System.out.println("两数之和是"+b);
        int[] c = testArray(5);
        for (int i = 0; i < c.length ; i++) {
            System.out.println("第"+(i+1)+"个数是"+c[i]);
        }

    }

    public static void say() {//无参无返回值
        System.out.println(28);
    }

    public static void sayHi(int age) {//有参无返回值
        System.out.println(age);
    }

    public static void sayHello(String name, int age) {//两个参无返回值
        System.out.println("我叫" + name + ",我今年" + age + "岁了");
    }

    public static int getNum() {
        return 25;
    }
    public static int plus(int num1,int num2){//两个参有返回值
        int sum = num1+num2;
        return sum;
    }
    public static int[] testArray(int b){//有参有返回值,返回值类型是数组类型
        int[] a = new int[b];
        for (int i = 0; i < a.length ; i++) {
            a[i] = (int)(Math.random()*101);
        }
        return a;
    }

}
